<template>
  <div>
    <el-dialog title="编辑" :visible.sync="status.isshow" width="30%">
      <el-form :v-model="form">
        {{form}}
        <el-form-item label="手机号" label-width="120px">
          <el-input v-model="form.phone" placeholder="请输入用户名"></el-input>
        </el-form-item>
        <el-form-item label="昵称" label-width="120px">
          <el-input v-model="form.nickname" placeholder="请输入昵称"></el-input>
        </el-form-item>
        <el-form-item label="密码" label-width="120px">
          <el-input v-model="form.password" show-password placeholder="请输入密码"></el-input>
        </el-form-item>
        <el-form-item label="状态" label-width="120px">
          <el-switch v-model="form.status" :active-value="1" :inactive-value="2"></el-switch>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="update">修改</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// import {mapGetters,mapActions} from "vuex"
import { successAlert ,errorAlert} from "../../../utils/alert";
import { reqmemberinfo, reqmemberedit} from "../../../http/api";
export default {
    props:["status"],
  data() {
    return {
      input: "",
      form: {
        uid: "",
        nickname: "",
        phone: "",
        password: "",
        status: 1
      }
    };
  },
  methods: {
    empty() {
      this.form = {
        uid: "",
        nickname: "",
        phone: "",
        password: "",
        status: 1
      };
    },
    getOne(uid){
        reqmemberinfo({
            uid:uid
        }).then(res=>{
            if(res.data.code==200){
                this.form=res.data.list
                this.form.password=""
                this.form.uid=uid
            }
        })
    },
    update(){
        if(this.form.nickname==""){
        errorAlert("用户昵称不能为空")
        return
      }
        if(this.form.phone==""){
        errorAlert("用户手机号不能为空")
        return
      }
        if(this.form.password==""){
        errorAlert("用户手机号不能为空")
        return
      }
      reqmemberedit(this.form).then(res=>{
          if(res.data.code==200){
              successAlert(res.data.msg)
              this.empty()
              this.status.isshow=false
              this.$emit("init")
          }
      })
    }
  }
};
</script>

<style>
</style>